<template>
  <div class="recentPlay">
    <div class="recentPlayTop">
      <span
        class="iconfont icon-xiazai6 icona"
        @click="$router.go(-1)"
      ></span>
      
      <div class="clouTopName">
        <h4>最近播放</h4>
      </div>
    </div>
        <!-- <div class="vanCell" v-for="(item,index) in list" :key="index" @click="recentPlay(item.song.id)">
          <div class="recentImg">
            <img :src="item.song.al.picUrl" alt="">
          </div>
          <div class="recentName">
            <h4>{{item.song.name}}</h4>
            <p><span v-for="item in item.song.ar" :key="item.id">{{item.name}} </span></p>
          </div>

       </div> -->
       
           <div class="musicList">
        <dd
          v-for="(item, index) in list"
          :key="index"
           @click="recentPlay(item.song.id)"
        >
          <h1>{{ index + 1 }}</h1>
          <div class="info">
            <div class="text">
              <h2>{{ item.song.name }}</h2>
              <h3>
                <span v-for="value in item.song.ar" :key="value.id">{{
                  value.name
                }}</span>
              </h3>
            </div>

            <div class="iconfont icon-yuandiancaidan bofang"></div>
          </div>
        </dd>
      </div>
  </div>
</template>

<script>
import { getUserRecord } from "../../api/user";
export default {
  data() {
    return {
      active: 0,
      list: [],
    };
  },
  methods:{
    recentPlay(id){
      console.log(id);
      this.$emit("recent-play",id)
      this.$emit("get-player-id", id);

    }
  },
  created() {
    let id = JSON.parse(localStorage.getItem("uid"));
    // console.log(id);
    getUserRecord({ uid: id }).then((data) => {
      this.list = data.allData;
      // console.log(this.list);
    });
    // getAlbumSub().then(data=>{
    //   console.log(data);
    // })
  },
};
</script>

<style lang="less">
.recentPlay {
  padding: 14px;
     .musicList {
    background-color: #fff;
    width: 100%;
    border-radius: 7px;
    position: relative;
    top: -7px;

    dt {
      height: 36px;
      line-height: 36px;
      font-size: 16px;
      color: #454747;
      border-bottom: 1px solid #e3e3e3;
      span {
        font-size: 14px;
        color: #797b7a;
      }
      i {
        width: 44px;
        text-align: center;
        display: inline-block;
      }
    }
    dd {
      border-bottom: 1px solid #e3e3e3;
      height: 53px;
      display: flex;
      h1 {
        flex: 0 0 44px;
        line-height: 53px;
        text-align: center;
        font-size: 16px;
        color: #6d6e6e;
      }
      .info {
        flex: 1;
        display: flex;
        justify-content: space-between;
        .text {
          h2 {
            font-size: 16px;
            color: #1b1c1c;
            margin-top: 10px;
          }
          h3 {
            font-size: 12px;
            color: #929393;
          }
        }
        .bofang {
          font-size: 24px;
          line-height: 53px;
          text-align: center;
          // padding-right: 5px;
            color: #929393;
            font-weight: 300;

        }
      }
    }
  }
  .recentPlayTop {
    width: 100%;
    height: 32px;
    display: flex;
    .icona {
      font-size: 18px;
    }
    .clouTopName {
      width: 100%;
      margin-top: -3px;
      margin-left: 4px;
      h4 {
        font-size: 18px;
      }
    }
  }
  
  .vanCell{
    height: 60px;
    padding-top: 26px;
    display: flex;
    .recentImg{
    
    width: 40px;
    height: 40px;
    // background-color: red;
    img{
      width: 100%;
      height: 100%;
    }
  }
  .recentName{
    width: 100%;
    margin-left: 12px;
    p{
      font-size: 12px;
      margin-top: 5px;
      color: #696969;
      word-break: break-all;
      overflow: hidden;
      text-overflow: ellipsis;
      display:-webkit-box;
      -webkit-line-clamp: 2;  /*设置行数 */
      -webkit-box-orient: vertical;
    }
  }
  }
}
</style>